package ref;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

/**
 * @author Mark
 * @date 2020/5/24 23:34
 * @description 泛型
 */
public class GenericClass {

    private void test(Map<String, User> map, List<User> list) {
        System.out.println("test01");

    }

    public static void main(String[] args) throws NoSuchMethodException {

        Method method = GenericClass.class.getDeclaredMethod("test", Map.class, List.class);
        Type[] genericExceptionTypes = method.getGenericParameterTypes();
        for (Type genericExceptionType : genericExceptionTypes) {
            System.out.println(" = " + genericExceptionType);
            if (genericExceptionType instanceof ParameterizedType) {
                Type[] actualTypeArguments = ((ParameterizedType) genericExceptionType).getActualTypeArguments();
                for (Type actualTypeArgument : actualTypeArguments) {
                    System.out.println("actualTypeArgument = " + actualTypeArgument);
                }
            }
        }
    }

}
